package com.ecloud.gardenscenter.service.mqtt;


import com.ecloud.gardenscenter.constant.TopicConstant;
import com.ecloud.gardenscenter.mqtt.MqttTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author Squbi
 */
@Component
public class MqttInitService implements InitializingBean {
    private static final Logger LOGGER = LoggerFactory.getLogger(MqttInitService.class);
    @Autowired
    private MqttTemplate template;

    @Override
    public void afterPropertiesSet() throws Exception {
        template.subscribe(TopicConstant.SERVER, 2);
        LOGGER.info("subscribe topic `{}`", TopicConstant.SERVER);
    }
}
